package com.miet.mp45.filippov.utils;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class IOUtilities
{
    
    public static byte[] readFile(String filePath) throws IOException
    {
        File file = new File(filePath);
        BufferedInputStream input = new BufferedInputStream(new FileInputStream(file));
        ByteArrayOutputStream output = new ByteArrayOutputStream(input.available());
        byte[] buffer = new byte[512];
        int count;
        while ((count = input.read(buffer)) > 0)
        {
            output.write(buffer, 0, count);
        }
        
        return output.toByteArray();
    }
    
}
